﻿using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

namespace ZXthex.EditorUI
{
    public class EditorCanvas
    {
        EUIWindow editorWindow;
        public Rect rect { get { return editorWindow.position; } }
        List<EditorRectTransform> children;
        public void AddChild(EditorRectTransform rectTransform)
        {
            if (children == null)
                children = new List<EditorRectTransform>(16);

            rectTransform.root = this;
            children.Add(rectTransform);
        }

        public int childCount
        {
            get
            {
                if (children == null)
                    return 0;
                return children.Count;
            }
        }

        public EditorRectTransform GetChild(int index)
        {
            if (children == null || children.Count <= index)
                throw new System.IndexOutOfRangeException(index.ToString());

            return children[index];
        }

        public EditorCanvas(EUIWindow window)
        {
            editorWindow = window;
        }

    }
}